package com.smart.redis.pubsub;

import redis.clients.jedis.JedisPubSub;

/**
 * 
* @ClassName: Subscriber 
* @Description: TODO 订阅者 
* @Company:e-smart.top
* @author Thinkpad 
* @version 1.0 2018年8月31日 下午5:57:45
 */
public class Subscriber extends JedisPubSub {

	@Override
	public void onMessage(String channel, String message) {//收到消息会调用
		System.out.println(String.format("receive redis published message, channel %s, message=> %s", channel, message));
	}
	@Override
	public void onSubscribe(String channel, int subscribedChannels) { //订阅了频道会调用
		System.out.println(String.format("subscribe redis channel success, channel %s, subscribedChannels %d",
                channel, subscribedChannels));
	}
	@Override
	public void onUnsubscribe(String channel, int subscribedChannels) { //取消订阅 会调用
		System.out.println(String.format("unsubscribe redis channel, channel %s, subscribedChannels %d",
                channel, subscribedChannels));
	}
	
	
	
	@Override
	public void onPMessage(String pattern, String channel, String message) {//取得按表达式的方式订阅的消息后的处理
		System.out.println(String.format("PMessage redis channel success, pattern %s, channel %s, message %d",
				pattern,channel, message));
	}
	@Override
	public void onPSubscribe(String pattern, int subscribedChannels) {//初始化按表达式的方式订阅时候的处理
		System.out.println(String.format("PSubscribe redis channel success, pattern %s, subscribedChannels %s",
				pattern,subscribedChannels));
	}
	@Override
	public void onPUnsubscribe(String pattern, int subscribedChannels) {//取消按表达式的方式订阅时候的处理
		System.out.println(String.format("PUnsubscribe redis channel success, pattern %s, subscribedChannels %s",
				pattern,subscribedChannels));
	}
	@Override
	public void onPong(String pattern) {
		super.onPong(pattern);
	}
}
